<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>社交账号绑定</title>
</head>
<script type="text/javascript" src="./assets/libs/layui/layui.js"></script>
<body>
    <script>
        layui.config({
            base:"./module/"
        })
        layui.use(['admin','config','layer'], function () {
            var $ = layui.jquery;
            var config = layui.config;
            var layer = layui.layer;
            var admin = layui.admin;
            var url =location.href;
            var i1 = url.indexOf("code=");
            if(i1 == -1){
                layer.msg("绑定失败");
                return;
            }
            var i2 = url.indexOf("&",i1);
            var code = url.substring(i1+5,i2);

            i1 = url.indexOf("state=");
            if(i1 == -1){
                layer.msg("绑定失败");
                return;
            }
            i2 = url.indexOf("&",i1);
            if(i2==-1){
                var state = url.substring(i1+6);
            }else{
                var state = url.substring(i1+6,i2);
            }
            console.log(code);
            console.log(state)
            admin.req("system/user/bind/"+state,{code:code},function (data) {
               layer.msg("绑定成功");
               setTimeout(function(){
                   window.close()
               },3000);
            })
        })
    </script>
</body>
</html>